<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<title>My HTML Template</title>
		<style type="text/css">
			div#header {
				color: #0066FF;
				font-size: 25pt;
			}
			
			div#content {
				color: #B088FF;
				font-size: 12pt;
			}
		</style>
		<script type="text/javascript">
			window.onload = function() {
				var divs = document.getElementsByTagName( "div" );
				
				// alert( "typeof( divs ) is " + typeof( divs ) );
				
				for( var element in divs ) {
					alert( "foreach working... " );
					// 因為有四個<div>標籤，包括開始與結尾標籤
					
					element.innerHTML = "Happy Day... ";
				}
				
				// alert( "the length of divs is " +  divs.length );
				
				for( var i = 0; i < divs.length; i++ ) {
					if( typeof( divs[i] ) == "undefined" ) {
						alert( "divs[i] is undefine" );
					}
					alert( "divs[" + i + "] id is : " + divs[i].id );
					divs[i].innerHTML = "Happy Div";
				}
				
			}
		</script>
		
	</head>
	
	<body>
		<div title="temp1" id="header">Hello HTML</div>
		<div title="temp1" id="content">Here is content</div>
	</body>
</html>k